package com.zhdl.modules.process.web.controller;

import com.zhdl.common.util.WebResult;
import com.zhdl.hardware_contact.hardware_config.entity.ProjectConfiguration;
import com.zhdl.modules.process.service.ProjectConfigProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(path = "/api/process", produces = MediaType.APPLICATION_JSON_VALUE)
public class ProcessWebController {

    @Resource
    private ProjectConfigProcessService projectConfigProcessService;

    /**
     * 读取配置信息中的参数
     *
     * @return /
     */
    @GetMapping("/param/projectConfig/read")
    public WebResult<List<ProjectConfiguration>> readRAMProjectConfig() {
        return WebResult.okResult(ProjectConfigProcessService.projectConfigurations);
    }

    /**
     * 设置配置信息中的参数
     *
     * @param projectConfiguration /
     * @return /
     */
    @PostMapping("/param/projectConfig/set")
    public WebResult<String> setRAMProjectConfig(@RequestBody ProjectConfiguration projectConfiguration) {
        String setResult = projectConfigProcessService.setPlcProjectConfig(projectConfiguration);
        return WebResult.okResult(setResult);
    }

}
